<?php
namespace DesignPatterns\Creational\Multition\Tests;

use PHPUnit\Framework\TestCase;
use DesignPatterns\Creational\Multiton\Multiton;

class MultitonTest extends TestCase {
    public function testUniqueness() {
        $firstCall = Multiton::getInstance(Multiton::INSTANCE_1);
        $secondCall = Multiton::getInstance(Multiton::INSTANCE_1);

        $this->assertInstanceOf(Multiton::class, $firstCall);

        $this->assertSame($firstCall, $secondCall);
    }
    public function testUniquenessForEveryInstance() {
        $firstCall = Multiton::getInstance(Multiton::INSTANCE_1);
        $secondCall = Multiton::getInstance(Multiton::INSTANCE_2);

        $this->assertInstanceOf(Multiton::class, $firstCall);
        $this->assertInstanceOf(Multiton::class, $secondCall);

        $this->assertNotSame($firstCall, $secondCall);
    }
}
